package first.progr.tc;

import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

import java.util.Random;

import org.testng.annotations.Test;

import first.progr.utils.SortedListOf;

public class ContactRemovingTests extends TestBase {

	@Test
	public void deleteSomeContact() throws Exception {
	   // Save old contacts state 
	   SortedListOf<ContactData> oldContactsList = app.getContactHelper().getContacts();
	   
	   Random rnd = new Random();
	   int index = rnd.nextInt(oldContactsList.size()-1);
	   
	   // Actions
	   app.getContactHelper().deleteContact(index);
	   
	   //Save new contacts state
	   SortedListOf<ContactData> newContactsList = app.getContactHelper().getContacts();
	   
	   // Compare states of lists
	   assertThat(newContactsList, equalTo(oldContactsList.without(index)));
    }
}

